package com.ruoyi.project.system.controller;

import java.util.List;

import com.ruoyi.project.system.service.ISysUserPariseService;
import io.swagger.annotations.Api;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.domain.SysUserParise;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 用户动态点赞Controller
 * 
 * @author jjp
 * @date 2020-04-16
 */
@RestController
@Api(description = "用户动态点赞")
@RequestMapping("/system/userParise")
public class SysUserPariseController extends BaseController
{
    @Autowired
    private ISysUserPariseService sysUserPariseService;

    /**
     * 查询用户动态点赞列表
     */
    @PreAuthorize("@ss.hasPermi('system:userParise:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysUserParise sysUserParise)
    {
        startPage();
        List<SysUserParise> list = sysUserPariseService.selectSysUserPariseList(sysUserParise);
        return getDataTable(list);
    }


    /**
     * 获取用户动态点赞详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:userParise:query')")
    @GetMapping(value = "/{pariseId}")
    public AjaxResult getInfo(@PathVariable("pariseId") Long pariseId)
    {
        return AjaxResult.success(sysUserPariseService.selectSysUserPariseById(pariseId));
    }

    /**
     * 新增用户动态点赞
     */
    @PreAuthorize("@ss.hasPermi('system:userParise:add')")
    @Log(title = "用户动态点赞", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysUserParise sysUserParise)
    {
        return toAjax(sysUserPariseService.insertSysUserParise(sysUserParise));
    }

    /**
     * 修改用户动态点赞
     */
    @PreAuthorize("@ss.hasPermi('system:userParise:edit')")
    @Log(title = "用户动态点赞", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysUserParise sysUserParise)
    {
        return toAjax(sysUserPariseService.updateSysUserParise(sysUserParise));
    }

    /**
     * 删除用户动态点赞
     */
    @PreAuthorize("@ss.hasPermi('system:userParise:remove')")
    @Log(title = "用户动态点赞", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pariseIds}")
    public AjaxResult remove(@PathVariable Long[] pariseIds)
    {
        return toAjax(sysUserPariseService.deleteSysUserPariseByIds(pariseIds));
    }


    /**
     * 查询用户动态点赞列表
     */
    @PreAuthorize("@ss.hasPermi('system:userParise:query')")
    @GetMapping(value = "/getDynamicIdInfo/{dynamicId}")
    public TableDataInfo getDynamicIdInfo(@PathVariable("dynamicId") Long dynamicId)
    {
        startPage();
        List<SysUserParise> list = sysUserPariseService.selectSysUserPariseByDynamicId(dynamicId);
        return getDataTable(list);
    }
}
